﻿using ConsoleApp.Infrastructure.Attributes;
using ConsoleApp.Util;
using Microsoft.Extensions.Logging;
using Quartz;
using System;
using System.Threading;
using System.Threading.Tasks;

namespace ConsoleApp.Job.QuartzJob
{
    /// <summary>
    /// 等待本次任务执行完才可以执行下次任务
    /// </summary>
    [DisallowConcurrentExecution]
    public class LogJob : IJob
    {
        private readonly ILogger<LogJob> _logger;
        public LogJob(ILogger<LogJob> logger)
        {
            _logger = logger;
        }
        [TaskInterceptor("LogJob", TaskLevel.Three)]
        public Task Execute(IJobExecutionContext context)
        {
            _logger.LogError("LogJob错误信息" + DateTime.Now.ToString());

			//Console.Write("Performing some task... ");
			//using (var progress = new ProgressBar())
			//{
			//	for (int i = 0; i <= 100; i++)
			//	{
			//		progress.Report((double)i / 100);
			//		Thread.Sleep(20);
			//	}
			//}
			//Console.WriteLine("Done.");

			return Task.CompletedTask;
        }
    }
}
